package com.hxkj.service.impl;

import com.hxkj.component.AliyunMessageComponent;
import com.hxkj.component.CloopenMessageComponent;
import com.hxkj.domain.po.CommonMessage;
import com.hxkj.service.MessageService;
import com.platform.common.domain.result.ResultDataStruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 短信服务实现类
 * <p>
 * Create by chenwei on 2018/7/9 14:30
 */
@Service("messageService")
@Slf4j
public class MessageServiceImpl implements MessageService {

    @Autowired
    private CloopenMessageComponent cloopenMessageComponent;
    @Autowired
    private AliyunMessageComponent aliyunMessageComponent;

    @Override
    public ResultDataStruct sendMessage(CommonMessage commonMessage) {
        String serviceId = commonMessage.getServiceId();
        switch (serviceId) {
            case "cms-management-router":
                return cloopenMessageComponent.sendMessage(commonMessage);
            case "insurance-app":
                return aliyunMessageComponent.sendMessage(commonMessage);
            default:
                return cloopenMessageComponent.sendMessage(commonMessage);
        }
    }

}
